package com.ruoyi.MtTakeaway.collerent;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.MtTakeaway.domain.Mthylj;
import com.ruoyi.MtTakeaway.service.IMthyljService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 美团Controller
 * 
 * @author 张
 * @date 2023-09-24
 */
@RestController
@RequestMapping("/MtTakeaway/mthylj")
public class MthyljController extends BaseController
{
    @Autowired
    private IMthyljService mthyljService;

    /**
     * 查询美团列表
     */
    @PreAuthorize("@ss.hasPermi('MtTakeaway:mthylj:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mthylj mthylj)
    {
        startPage();
        List<Mthylj> list = mthyljService.selectMthyljList(mthylj);
        return getDataTable(list);
    }

    /**
     * 导出美团列表
     */
    @PreAuthorize("@ss.hasPermi('MtTakeaway:mthylj:export')")
    @Log(title = "美团", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mthylj mthylj)
    {
        List<Mthylj> list = mthyljService.selectMthyljList(mthylj);
        ExcelUtil<Mthylj> util = new ExcelUtil<Mthylj>(Mthylj.class);
        util.exportExcel(response, list, "美团数据");
    }

    /**
     * 获取美团详细信息
     */
    @PreAuthorize("@ss.hasPermi('MtTakeaway:mthylj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mthyljService.selectMthyljById(id));
    }

    /**
     * 新增美团
     */
    @PreAuthorize("@ss.hasPermi('MtTakeaway:mthylj:add')")
    @Log(title = "美团", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mthylj mthylj,HttpServletResponse response)
    {
        return toAjax(mthyljService.insertMthylj(mthylj,response));
    }

    /**
     * 修改美团
     */
    @PreAuthorize("@ss.hasPermi('MtTakeaway:mthylj:edit')")
    @Log(title = "美团", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mthylj mthylj)
    {
        return toAjax(mthyljService.updateMthylj(mthylj));
    }

    /**
     * 删除美团
     */
    @PreAuthorize("@ss.hasPermi('MtTakeaway:mthylj:remove')")
    @Log(title = "美团", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mthyljService.deleteMthyljByIds(ids));
    }
}
